#include "read_file.h"


/*
从任何文件读取，返回的结果是二进制list，每10000字节为一组;
如果文件不存在，返回空指针！
*/
ByteArrayList *readFromFile(QString fileName){
    QFile qfile(fileName);
    if(!qfile.exists()){
        return nullptr;
    }

    qfile.open(QFile::ReadOnly);
    int count = qfile.size();
    int maxSize = 10000;
    int times = count/maxSize+1;
    ByteArrayList *list = new ByteArrayList();

    QByteArray qb;
    for(int i = 0;i < times;i++){
        qb = qfile.read(maxSize);
        list->appendArray(qb);
    }

    qfile.close();

    return list;
}

